package com.zt.fbg.autogenerator.config;

import com.zt.fbg.autogenerator.util.LanguageUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;

import java.util.Locale;

@Configuration
public class LanguageConfig {

    @Bean
    public LanguageUtil languageUtil(){
        return new LanguageUtil(messageSource());
    }

    @Bean
    public ResourceBundleMessageSource messageSource(){
        Locale.setDefault(Locale.CHINESE);
        ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
        resourceBundleMessageSource.setBasenames("static.i18n.messages.button");
        resourceBundleMessageSource.setUseCodeAsDefaultMessage(true);
        resourceBundleMessageSource.setDefaultEncoding("UTF-8");
        return resourceBundleMessageSource;
    }

}
